﻿DEUBG = -D_DEBUG

TARGET = media

OBJS_PATH = objs
TOP_PATH = $(shell pwd)

CROSS_COMPILE ?= aarch64-none-linux-gnu-
CXX   = $(CROSS_COMPILE)g++
CC    = $(CROSS_COMPILE)gcc
STRIP = $(CROSS_COMPILE)strip

INC  = -I$(TOP_PATH)/src/ -I$(TOP_PATH)/include
INC += -I$(TOP_PATH)/src/net -I$(TOP_PATH)/src/xop -I$(TOP_PATH)/src/3rdpart -I$(TOP_PATH)/src/camera -I$(TOP_PATH)/src/encoder
LIB  = -L$(TOP_PATH)/lib

LD_FLAGS  = -lrt -pthread -lpthread -ldl -lm -lx264 $(DEBUG) $(LIB)
CXX_FLAGS = -std=gnu++11 -D__linux -D__linux__

O_FLAG = -O2

DIRS = src src/3rdpart src/camera src/net src/xop src/encoder
# 找到指定目录下的所有.cpp文件
SOURCES := $(foreach dir,$(DIRS),$(wildcard $(dir)/*.cpp))
# 对象文件
OBJECTS := $(SOURCES:.cpp=.o)



all: $(TARGET)

$(TARGET) : $(OBJECTS)
	$(CXX) $^ -o build/$@ $(CFLAGS) $(LD_FLAGS) $(CXX_FLAGS)
    
%.o: %.cpp
	$(CXX) -c  $< -o  $@  $(CXX_FLAGS) $(INC)

clean:
	-rm -f $(OBJECTS) $(TARGET)